package com.qp;

/**
 * Created with IntelliJ IDEA.
 * User: bigmar
 * Date: 12/11/14
 * Time: 1:33 PM
 * To change this template use File | Settings | File Templates.
 */
public class CMatrixCalculator {
    public static double[][] calculate(double[] mixtureDistribution, double[][] kMatrix)
    {

        int numberOfModels=mixtureDistribution.length;

        int length=numberOfModels*numberOfModels;
        double[][] retVal=new double[length][length];
        for (int i=0; i<numberOfModels; ++i)
            for (int j=0; j<numberOfModels; ++j)
                for (int k1=0; k1<numberOfModels;++k1)
                    for (int k2=0; k2<numberOfModels;++k2)

                    {
                        int rowIndex=k1*numberOfModels+k2;
                        int colIndex=i*numberOfModels+j;

                        retVal[rowIndex][colIndex]=kMatrix[k1][j]*kMatrix[k2][i]*mixtureDistribution[j];

                    }

        return retVal;
    }
}
